package com.sunyard.dal.mapper;

import com.sunyard.dal.bo.device.key.KeyWarningQueryBO;
import com.sunyard.dal.bo.device.lock.LockWarningQueryBO;
import com.sunyard.dal.bo.device.TerminalDeleteBO;
import com.sunyard.dal.bo.device.TerminalQueryBO;
import com.sunyard.dal.bo.device.key.KeyWarningQueryBO;
import com.sunyard.dal.bo.device.lock.LockWarningQueryBO;
import com.sunyard.dal.dto.KeyWarningQueryDTO;
import com.sunyard.dal.dto.LockWarningQueryDTO;
import com.sunyard.dal.dto.RegionTerminalDTO;
import com.sunyard.dal.dto.TerminalWarningQueryDTO;
import com.sunyard.dal.entity.Terminal;
import com.sunyard.dal.entity.TerminalExport;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;

public interface TerminalMapper {
    /**
     * delete by primary key
     *
     * @param id primaryKey
     * @return deleteCount
     */
    int deleteByPrimaryKey(Integer id);

    /**
     * insert record to table
     *
     * @param record the record
     * @return insert count
     */
    int insert(Terminal record);

    /**
     * insert record to table selective
     *
     * @param record the record
     * @return insert count
     */
    int insertSelective(Terminal record);

    /**
     * select by primary key
     *
     * @param id primary key
     * @return object by primary key
     */
    Terminal selectByPrimaryKey(Integer id);

    /**
     * update record selective
     *
     * @param record the updated record
     * @return update count
     */
    int updateByPrimaryKeySelective(Terminal record);

    /**
     * update record
     *
     * @param record the updated record
     * @return update count
     */
    int updateByPrimaryKey(Terminal record);

    /**
     * 分页查询终端信息
     *
     * @param terminalQueryBO [terminalQueryBO]
     * @return List<Terminal>
     **/
    List<Terminal> getTerminalByPage(TerminalQueryBO terminalQueryBO);

    /**
     * 根据终端名称获取终端信息(如果id不为空，则获取当前id之外的)
     *
     * @param name name
     * @param id   [name, id]
     * @return Terminal
     **/
    Terminal getTerminalByName(@Param("name") String name, @Param("id") Integer id);

    /**
     * 通过Mac地址查询终端信息
     *
     * @param mac [mac]
     * @return Terminal
     **/
    Terminal getTerminalByMac(String mac);

    Terminal getTerminalByMacAndOrgIds(String mac,List<String> orgIds);

    List<Terminal> selectByMacAndId(@Param("mac") String mac, @Param("id") String id);

    /**
     * 获取终端信息列表
     *
     * @return Terminal
     **/
    List<Terminal> getTerminalList(String type);

    /**
     * @Description: 终端预警查询
     * @author wxl
     * @date 2022年7月11日
     */
    List<KeyWarningQueryDTO> queryKeyWarning(KeyWarningQueryBO queryBO);

    /**
     * @Description: 锁具预警查询
     * @author wxl
     * @date 2022年7月11日
     */
    List<LockWarningQueryDTO> queryLockWarning(LockWarningQueryBO lockWarningQueryBO);

    /**
     * @Description: 终端预警查询New
     * @author wxl
     * @date 2022年7月12日
     */
    List<TerminalWarningQueryDTO> queryKeyWarningNew(KeyWarningQueryBO queryBO);

    /**
     * @Description: 锁具预警查询New
     * @author wxl
     * @date 2022年7月12日
     */
    List<TerminalWarningQueryDTO> queryLockWarningNew(LockWarningQueryBO lockWarningQueryBO);

    void updateTerminalSn(Integer terminalId);

    void updateByAdminId(String adminId);

    Integer getLastInsertId();

    List<Terminal> selectByName(String name);

    List<Terminal> selectByNames(@Param("names") List<String> names);

    void updateById(String id);

    //辖区内设备种类统计
    List<RegionTerminalDTO> getRegionTerminalType(@Param("orgIds") List<String> orgIds);

    Terminal queryPdaId(String pdaId);

    Terminal queryRfid(String rfid);

    Terminal queryTrunkSn(String trunkSn);

    List<Terminal> queryByTrunkType(@Param("lockOne") String lockOne, @Param("lockTwo") String lockTwo);

    String queryByTrunkOne(String one);

    List<Terminal> selectAll(List<Integer> list);

    List<Terminal> queryByTrunkLock(@Param("id") String id, @Param("ids") String ids);

    void updateByTrunkLockOne(List<String> list);

    void updateByTrunkLockTwo(List<String> list);

    List<Terminal> selectAllTrunk();

    List<Terminal> selectAllLock();

    int getTerminalCountByOrgId(@Param("orgIds") List<String> orgIds);

    Map<String, String> selectInfoById(@Param("delete") TerminalDeleteBO deleteBO);

    int getUnSignNumber(String orgId);

    /**
     *
     * @author wp
     * @date 2022/11/2
     * @param terminalSn 0-钥匙终端，1-锁终端
     * @param type
     * @return com.sunyard.dal.entity.Terminal
     * @throws
    */
    Terminal getTerminalBySn(@Param("terminalSn") String terminalSn,@Param("type")String type);

    Terminal getTerminalBySnAndDelete(@Param("terminalSn")String terminalSn,@Param("type")String type);

    int getCountByAdminId(String opId);

    int deleteTerminalByAdminId(String adminId);

    List<String> getKeyOrgidList();

    void resetLock();

    void resetLockOrg(Integer id);

    int getCountByTaskTypeName(String taskTypeName);

    void updateByTaskTypeName(@Param("taskTypeName") String taskTypeName,@Param("taskTypeNameNew") String taskTypeNameNew);

    List<Terminal> getResetLock();

    List<Terminal> getTerminalByListSn(@Param("terminalSn") List<String> terminalSn);

    List<TerminalExport> getTerminalByCondition(TerminalQueryBO terminalQueryBO);

    int getTerminalName(@Param("name") String name,@Param("type") String type,@Param("orgId") String orgId,@Param("id") String id);

    int countOperatorByRole(@Param("role") String role);
}